<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

$pagecount=getnums($_GET["pagecount"],$GLOBALARR['pagecount']);
$options=getnums($_GET['options'],1);
$orderby=getnums($_GET['orderby'],1);
$quser=trim($_GET['quser']);


$tmp_arr['toption'].='<a href="'.getqueurl('options',1).'" class="'.geteqval(array($options,1,'taselbtn','thabtn')).'">所有推荐</a>';

if(is_array($GLOBALARR['jjname'])){
foreach ($GLOBALARR['jjname'] as $k => $v) {
	$tmp_arr['toption'].='<a href="'.getqueurl('options',$k+2).'" class="'.geteqval(array($options,$k+2,'taselbtn','thabtn')).'">'.$v.'</a>';
}
}

$tmp_arr['torderby']='<a href="'.getqueurl('orderby',geteqval(array($orderby,1,'2','1'))).'" class="'.((strstr($orderby,'1')||strstr($orderby,'2'))?"tpaixusel":"tpaixu").'">'.geteqval(array($orderby,1,'时间↓','时间↑')).'</a>';


$tmp_arr['tcolor']='<a href="javascript:;" class="theacolor statuscolor0">未正式</a><a href="javascript:;" class="theacolor statuscolor1">已正式</a><a href="javascript:;" class="theacolor statuscolor2">空单</a>';



$qid=getnums($_GET["qid"],$_houid);

$quser=trim($_POST["quser"]);
if(!empty($quser)){
  $r=$member->user_exists($quser);
  if(empty($r)){
  	$condition=' where introducer_id='.$qid;
  }else{
 	 $qid=$r['id'];
  	 $condition=' where id='.$qid;

	if(!strstr($r['parents_ids'],",".$_houid.",") && $r["id"]!=$_houid){
	   show_automsg('查询失败!',$GLOBALARR['curl'],1,3,0);
	}
  }
}else{
	$condition=' where introducer_id='.$qid;
}

if($options>1) $condition.=" and  user_level=".($options-2);


$order='';
if($orderby==1) $order=' order by regist_time desc';
if($orderby==2) $order=' order by regist_time asc';


$tmp_arr['tth']='<th>序号</th><th>会员账号</th><th>姓名</th>';
if(is_array($GLOBALARR['jjname'])){	
$tmp_arr['tth'].='<th>级别</th>';
}
$tmp_arr['tth'].='<th>推荐数</th><th>推荐人</th>';

$tmp_arr['tth'].='<th>开通时间</th>';

$psql="select count(0) from ld_user_account $condition";
$db->query($psql,3);
$pcount=$db->fval;
$pagecount=$pagecount;   //每页条数 
$astr="&lsaction=networkmap&pagecount=$pagecount&orderby=$orderby&options=$options&option=$option&quser=$quser";	  //Url
$pagearr=pagelist($pagecount,$pcount,$astr);
$offset=$pagearr[1];

$sql="select * from ld_user_account  $condition $order limit $offset,$pagecount";
$db->query($sql);
$ii=0;
foreach ($db->rs as $k => $v) {

	$ii++;
	$serialid=($pagearr[2]-1)*$pagecount+$ii;
	$tmp_arr['ttr'].='<tr class="statuscolor'.$v['is_passed'].'">
						<td><span  title="'.$v["id"].'">'.$serialid.'</span></td>
						<td><a href="'.$GLOBALARR['curl'].'&option=3&qid='.$v['id'].'">'.$v['uname'].'</a></td>
						<td>'.$member->getusername($v['id']).'</td>';
if(is_array($GLOBALARR['jjname'])){						
$tmp_arr['ttr'].='<td>'.getlevel($v['user_level']).'</td>';
}						
$tmp_arr['ttr'].='<td>'.$v['recommend_unum'].'</td>	
						<td>'.$member->getuserid($v['introducer_id']).'</td>';

	$tmp_arr['ttr'].='<td>'.formatdate($v['open_time']).'</td>	
						</tr>';
}


$tmp_arr['tcount']=$pcount;
$tmp_arr['ttitle']=getmenu($GLOBALARR['menu'],'articlelist');
$tmp_arr['tpage']=$pagearr[0];
admin_four($tmp_arr);

?>